// Package na
// Date        : 2023/3/9 15:33
// Version     : 1.0.0
// Author      : 代码小学生王木木
// Email       : 18574945291@163.com
// Description :
package na

import (
	"github.com/gin-gonic/gin"
	"pingbuqingyun_django/app/models/form"
	"pingbuqingyun_django/app/services/admin"
	"pingbuqingyun_django/pkg/tools"
)

func RegisterAPI(ctx *gin.Context) {
	regForm := form.RegUserForm{}
	if err := ctx.ShouldBindJSON(&regForm); err != nil {
		tools.HandleValidatorError(ctx, err)
		return
	}
	user, err := admin.UserService.RegUser(&regForm)
	if err != nil {
		tools.JsonErrorResp(ctx, err)
		return
	}
	tools.JsonSuccessData(ctx, "创建用户成功！", user)
	return
}
